using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Hector.Api;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
	public class ExecutionResult<T> : ResultStatus
	{
		private const int MICRO_DENOM = 1000;
        protected internal const System.String BASE_MSG_FORMAT = "{0} took {1} for query {2} on host: {3}";
        public ExecutionResult(T result, long execTime, CassandraHost cassandraHost)
        {
            Get = result;
            ExecutionTimeNano = execTime;
            HostUsed = cassandraHost;
        }
        public T Get
        {
            get;
            set;
        }
		public long ExecutionTimeNano
		{
			get;
            protected set;
		}
		public long ExecutionTimeMicro
		{
			get
			{
				return ExecutionTimeNano / MICRO_DENOM;
			}
		}
		public CassandraHost HostUsed
		{
			get;
			protected set;
		}
		public override string ToString()
		{
			return FormatMessage("ExecutionResult", "n/a");
		}
		protected internal virtual string FormatMessage(System.String resultName, System.String query)
		{
            return string.Format(BASE_MSG_FORMAT, resultName, ExecutionTimeMicro, query, (HostUsed != null ? HostUsed.Name : "[none]"));
		}
	}
}